package event;

/**
 * 主程序-子程序风格
 */

public class MainProgramSubroutine {
    public static String process() {
        String[] lines = {
            "Liu Jin Qi is learning",
            "Software architecture is essential",
            "Understanding design patterns is crucial"
        };
        StringBuilder result = new StringBuilder();
        for (String line : lines) {
            result.append(kwicShift(line)).append("\n");
        }
        return result.toString();
    }

    private static String kwicShift(String line) {
        String[] words = line.split(" ");
        StringBuilder shifted = new StringBuilder();
        for (int i = 0; i < words.length; i++) {
            for (int j = i; j < words.length; j++) {
                shifted.append(words[j]).append(" ");
            }
            for (int k = 0; k < i; k++) {
                shifted.append(words[k]).append(" ");
            }
            shifted.append("\n");
        }
        return shifted.toString();
    }
}
